package com.crl.utils.timer
{
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	

	
	/**
	 *  唯一实例的的侦听enterFrame类
	 * @author crl
	 * 
	 */	
	public class EnterFrame extends EventDispatcher
	{
		private var _shape:Shape;
		
		public function EnterFrame()
		{
			if(_instance !=null){
				throw new Error("");
			}
			_shape = new Shape();
			_shape.addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		private static var _instance:EnterFrame;
		static public function getInstance():EnterFrame{
			if(_instance==null){
				_instance=new EnterFrame();
			}
			return _instance;
		}
		
		
		/**
		 * 使默认为弱引用; 
		 * @param type
		 * @param listener
		 * @param useCapture
		 * @param priority
		 * @param useWeakReference
		 * 
		 */		
		override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=true) : void{
			super.addEventListener(type,listener,useCapture,priority,useWeakReference);
		}
		
		
		protected function onEnterFrame(e:Event):void
		{
			dispatchEvent(e);
		}
	}
}